﻿using System;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.Workflow;

namespace MS.InformationManagement.Documents.ObjectDef.ItemReceivers.ContactsReceiver
{
    /// <summary>
    /// List Item Events
    /// </summary>
    public class ContactsReceiver : SPItemEventReceiver
    {
       /// <summary>
       /// An item is being deleted.
       /// </summary>
       public override void ItemDeleting(SPItemEventProperties properties)
       {
           try
           {
               if (properties.List.Title.Equals("Contactos Externos"))
               {
                   base.ItemDeleting(properties);
                   properties.Cancel = true;
                   properties.ErrorMessage = "Usted no posee los privilegios necesarios para eliminar este item";
               }
           }
           catch (Exception ex)
           {
               //TODO: manejar excepción
               throw;
           }
           finally 
           { 
               this.EventFiringEnabled = true;  
           }

       }


    }
}
